/**
 * Created by qingmai on 2017/2/17.
 */
var gulp = require('gulp'),
    config = require('../config'),
    fileinclude  = require('gulp-file-include'),
    sourcemaps = require('gulp-sourcemaps'),
    notify = require('gulp-notify'),
    plumber = require('gulp-plumber'),
    del = require('del'),
    livereload = require('gulp-livereload');

gulp.task('htmlto', function(cd) {
   del(config.dest.delimage, {dryRun: true}).then(paths => {});
    return gulp.src(config.src.html)
        .pipe(plumber({errorHandler: notify.onError('有错误: <%= error.message %>')}))
        .pipe(fileinclude({
            prefix: '@@',
            basepath: '@file'
        }))
        .pipe(gulp.dest(config.dest.html))
        .pipe(livereload());  //浏览器刷新
});
gulp.task('html',function () {
    livereload.listen();
    gulp.watch(config.src.htmldel,['htmlto'])
})